<template lang="jade">
    div(v-loading="loading")
        div(v-if="paged.items.length==0")
            p(style="text-align:center;padding:20px;") 没有出入库记录
        el-card(v-for="item in paged.items",style="margin-bottom:10px;",:key="item.id")
            div(slot="header",class="clearfix")
                div(class="pull-left") 
                    strong {{item.title}}
                div(class="pull-right")
                    span(class="label label-info",style="margin-right:10px") 出/入库时间:{{item.createAt}}
                    span(class="label label-primary",v-if="item.type=='出库'") {{item.type}}
                    span(class="label label-success",v-if="item.type=='入库'") {{item.type}}
            el-table(:data="item.items",border)
                el-table-column(prop="productName",label="产品名称")
                el-table-column(prop="propertyInfo",label="产品属性",width="300px")
                el-table-column(prop="price",label="价格",width="100px")
                el-table-column(prop="total",label="出/入库数量",width="100px")
                el-table-column(prop="remark",label="备注")
        common-pagination(v-if="paged.items.length>0",v-model="page", :total="paged.totalCount", @change="getHistory")
         
</template>
<script>
    import {request,pagination} from 'collection';
    export default {
        data(){
            return {
                loading:false,
                paged:{items:[]},
                page:{maxResultCount:10,skipCount:0},
                filter:{productSkuId: null,productId:null}
            }
        },
        components:{
            'common-pagination': pagination
        },
        methods:{
            getHistory(){
                var vm = this;
                var params = _.extend({}, this.filter, this.page)

                request.get.call(this, '/api/services/app/Warehousing/GetHistory', params).then((res)=>{
                    vm.paged = res.data.result;
                });
            }
        },
        mounted(){
            this.filter.productSkuId=this.$route.params.productSkuId;
            this.getHistory();
        }
    }
</script>